import api from './api'; // 引入api.js中的axios实例

//搜索药品
export const searchDrugs = async (query) => {
    try {
        const response = await api.get(`/api/drugs/search`, {
            params: { name: query }
        });
        return response.data;
    } catch (error) {
        console.error('searchDrugs error:', error);
        throw error;
    }
};

// 获取药品列表
export const getDrugs = async () => {
    try {
        const response = await api.get('/api/drugs');
        return response.data;
    } catch (error) {
        console.error('getDrugs错误:', error);
        throw error;
    }
};
